<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!-- 1、创建按钮 2、按钮点击后成为禁用状态 3、倒计时后要重新获取 -->
    <button >获取验证码</button>
    <script>
        var num=10;
        document.querySelector("button").onclick=function(){
           var that=this
          var timer= setInterval(function(){
            num--;
            if(num>=0){
                that.innerText=num+`s重新获取`;
                that.disabled=true;
            }else{
                clearInterval(timer);
                that.innerText=`重新获取`;  
                that.disabled=false;
                num=10;
            } 
           },1000)
        }
    </script>
</body>
</html>